import request from "@/utils/request.js";

// 获取头像
export const getAvatar = (data) => {
  return request("avatar", "GET", data);
};
//登录
export const login = (data) => {
  let avatar = "";
  getAvatar({ type: "json" }).then((res) => {
    console.log(res);
    avatar = res.avatar;
  });
  // 等待两秒后返回数据
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve({
        code: 200,
        msg: "登录成功",
        data: {
          token: "I am login token",
          userInfo: {
            name: data.account,
            age: 18,
            avatar: avatar,
          },
        },
      });
    }, 3000);
  });
};
